﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using nplJobsCommon.Common;

namespace nplJobsDAL.Select
{
    public class SelectLanguageProficiency: DataAccessBase
    {
        public SelectLanguageProficiency()
        {
            StoredProcedureName = StoredProcedure.Name.spSelectLanguageProficiency.ToString();
        }

        #region GetLanguageProficiency
        public List<LanguageProficiency> GetLanguageProficiency()
        {
            DataBaseHelper dbHelper;
            DataSet dsLanguageProficienc;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsLanguageProficienc = dbHelper.Run(base.ConnectionString);
                return GetList(dsLanguageProficienc);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<LanguageProficiency> GetList(DataSet dsLanguageProficienc)
        {
            List<LanguageProficiency> languageProficiencies;
            try
            {
                languageProficiencies = (from n in dsLanguageProficienc.Tables[0].AsEnumerable()
                             select new LanguageProficiency
                                   {
                                       ID = n.Field<int>("ID"),
                                       Proficiency = n.Field<string>("Proficiency")
                                   }).ToList();

                return languageProficiencies;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }

}
